package org.hepeng.commons.spring.cloud.config;


import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.cloud.config.server.environment.EnvironmentRepository;
import org.springframework.context.annotation.Bean;

/**
 * @author he peng
 */

@ConditionalOnWebApplication
public class DynamicConfigRepositoryMvcConfiguration {


    @Bean
    @ConditionalOnMissingBean(AlterConfigRepositoryRequestParamHandler.class)
    public AlterConfigRepositoryRequestParamHandler simpleAlterConfigRepositoryParamHandler() {
        return new SimpleAlterConfigRepositoryParamHandler();
    }

    @Bean
    public ConfigRepositoryController configRepositoryController(
            AlterConfigRepositoryRequestParamHandler requestParamHandler ,
            EnvironmentRepository repository) {
        return new ConfigRepositoryController(requestParamHandler , repository);
    }
}
